package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.SystemDictionary;
import cn.wolfcode.crm.domain.SystemDictionaryBill;
import cn.wolfcode.crm.service.ISystemDictionaryService;
import cn.wolfcode.crm.util.PermissionName;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("systemDictionary")
public class SystemDictionaryController {

    @Autowired
    private ISystemDictionaryService service;

    /*字典首页*/
    @RequestMapping("index")
    public String index(){
        //查找到并共享到页面
        return "systemDictionary/list";
    }

    @RequiresPermissions("systemDictionary:list")
    @PermissionName("字典列表")
    @ResponseBody
    @RequestMapping("list")
    public List<SystemDictionary> list(){

        return service.selectAll();
    }

    @RequiresPermissions("systemDictionary:queryDictionaryBillByParentId")
    @PermissionName("字典明细查询")
    @ResponseBody
    @RequestMapping("queryDictionaryBillByParentId")
    public List<SystemDictionaryBill> queryDictionaryBillByParentId(Long pId){
        return service.queryDictionaryBillByParentId(pId);
    }
}
